/**
 * PHOSIDE: PHosphorylation Site IDentification Engine.
 * Copyright 2009 Digital Biology Lab, University of Missouri.
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version. <p/> This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more
 * details.
 */

package phoside.disorder;

import phoside.io.fasta.parser.HeaderRule;
import phoside.io.fasta.util.DefaultFastaTraveler;
import phoside.io.fasta.util.FastaVisitor;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import java.io.IOException;

/**
 *
 * @author gjj
 */
public class DisorderInfoBatchRetrieverFromPrediction
        implements DisorderInfoBatchRetriever {

    private final String rawFasta;
    private final HeaderRule headerRule;
    private final DisorderPredictor predictor;

    public DisorderInfoBatchRetrieverFromPrediction(final String rawFasta,
            final HeaderRule headerRule,
            final DisorderPredictor predictor) {
        if (rawFasta==null || headerRule==null || predictor==null) {
            throw new NullPointerException();
        }

        this.rawFasta = rawFasta;
        this.headerRule = headerRule;
        this.predictor = predictor;
    }
    /**
     *
     * @return map from accession to disorder score
     */
    public Map<String,List<Double>> retrieve() throws IOException {
        Map<String,List<Double>> mapAccDisorder = new LinkedHashMap<String,List<Double>>();

        FastaVisitor visitor
                = new DisorderPredictionFastaVisitor(mapAccDisorder,
                                                     headerRule,
                                                     predictor);

        DefaultFastaTraveler traveler = new DefaultFastaTraveler(rawFasta, visitor);
        traveler.travel();
        return mapAccDisorder;
    }
}
